﻿using System;
using System.Collections.Generic;
using System.Text;

using Lon.DataStore;

namespace Lon.Server
{
    delegate void SocketReceivedHandler(object sender, byte[] buffer, int length);
    delegate void SocketSendHandler(object sender, DataFrame pkgData);
    public abstract class DataProcessProvider
    {
                
        public virtual void Init()
        {
        }

        public virtual void Start()
        {
        }

        protected virtual void ProcessDataPackage(DataFrame pkgData)
        {
        }

        protected virtual void ProcessCommandPackage(DataFrame pkgData)
        {
        }

        public virtual void Process(DataFrame pkgData)
        {
            if (pkgData.IsCommand)
            {
                //处理命令包
                ProcessCommandPackage(pkgData);
            }
            else
            {
                //处理数据包
                ProcessDataPackage(pkgData);
            }
        }

      

        #region 属性

        private static IDataAccessService dataStoreService = null;

        public static IDataAccessService DataStoreService
        {
            get 
            {
                if (dataStoreService == null)
                {
                    DataProcessProvider.dataStoreService=DataAccessSeriveFactory.GetService(null);
                }
                return DataProcessProvider.dataStoreService; 
            }
            set 
            { 
                DataProcessProvider.dataStoreService = value; 
            }
        }




        #endregion

    }


    
  

}
